package com.nanxhs.concurrent.thread.over;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * 线程结束测试类
 *
 * @author: haibin.tang
 * @date: 2021/1/27
 */
public class ThreadOverMain {

    public static void main(String[] args) {
        Thread stopRunner = new Thread(new GenericSequenceRunner());
        Thread interruptedRunner = new Thread(new GenericSequenceRunner());
        stopRunner.start();
        interruptedRunner.start();
        LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));
        //线程立即就终止了
        stopRunner.stop();
        //线程不会立即终止，是否终止由代码逻辑自己控制
        interruptedRunner.interrupt();
    }
}
